import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import SelectCommon from 'code/Core/Common/SelectCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 嗜血术
 **/
export default class SM_BloodLust extends AbilityBase {
    static instance: SM_BloodLust;
    buffType: AppBuffType = {
        id: 'buff_SM_BloodLust',
        art: this.art,
        name: this.abilityName,
        ubertip: '增加大量的攻速与法术冷却速度',
        dur: 6,
        attribute: {
            attackSpd_p: 3,
            冷却_嗜血术: 0.5,
        },
        targetAttach: 'overhead',
        targetArt: 'Abilities\\Spells\\Orc\\Bloodlust\\BloodlustTarget.mdl',
    };
    constructor(id: string = 'Asxs') {
        super(id);
        SM_BloodLust.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let dur = this.getAbilityLevel(source) + 5;
        let us = SelectCommon.getAllyUnitInRange(source, 900);
        for (let u of us) {
            // let buff = BuffUtil.addBuff(u, this.buffType.id, source);
            // buff.durMS = dur * 1000;
            BuffCommon.addBuff({ target: u, caster: source, buffTypeId: this.buffType.id, ablityId: this.id, config: { dur } });
        }
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
